# import pymongo
# client = pymongo.MongoClient('127.0.0.1', 27017)  # 连接并建立client.
# db = client['llsdb']  # select database_name db = client.llsdb
# stu = db['student']   # select table_name   stu = db.student
#
# stu.insert_one({'name': 'lls'})
# stu.insert_many([
#   {'name1': 'lls1', 'age': 18},
#   {'name2': 'lls2', 'age': 20},
#   {'name3': 'lls3', 'age': 30}
# ])
# stu.update_one({'name1': 'lls1'}, {'$set': {'age': 20}})
# stu.update_many({'name2': 'lls2'}, {'$set': {'age': 90}})
# print(stu.find_one({'name2': 'lls2'}))  # 查询无args的第一行,或匹配到的第一个行.
# content_find = stu.find({})   # 空字典表示查询所有.
# print(content_find)
# for i in content_find:
#   print(i)
# print(stu.delete_many({'name': 'lls'}).deleted_count)
# print(stu.delete_many({}).deleted_count)


import csv
# mydict = {1: 11, 2: 22, 3: 33}
# print(mydict)
# print(mydict[1])
#
# writer = csv.writer(open('dict.csv', 'wb'))
# for key, value in mydict.items():
#     writer.writerow([str(key).encode(), str(value).encode()])


# import csv
# headers = ['class', 'name', 'sex', 'height', 'year']
#
# rows = [
#     {'class': 1, 'name': 'xiaoming', 'sex': 'male', 'height': 168, 'year': 23},
#     {'class': 1, 'name': 'xiaohong', 'sex': 'female', 'height': 162, 'year': 22},
#     {'class': 2, 'name': 'xiaozhang', 'sex': 'female', 'height': 163, 'year': 21},
#     {'class': 2, 'name': 'xiaoli', 'sex': 'male', 'height': 158, 'year': 21},
# ]
#
# with open('test2.csv', 'w', newline='')as f:
#     f_csv = csv.DictWriter(f, headers)
#     # f_csv.writeheader()
#     f_csv.writerows(rows)


import numpy as np
import matplotlib.pyplot as plt
from sklearn.linear_model import LinearRegression

#模拟数据
# x = np.linspace(0, 10, 50)
# noise = np.random.uniform(-2,2,size=50)
# y = 5 * x + 6 + noise
# #创建模型
# liner = LinearRegression()
# #拟合模型
# liner.fit(np.reshape(x,(-1,1)),np.reshape(y,(-1,1)))
# print(liner)
# #预测
# y_pred = liner.predict(np.reshape(x,(-1,1)))
# plt.figure(figsize=(5,5))
# plt.scatter(x,y)
# plt.plot(x,y_pred, color="r")
# plt.show()
# print(liner.coef_)
# print(liner.intercept_)

# m = 1 if 1 < 5 else 2
#
# print(m)


        # 触发异常后，后面的代码就不会再执行
# try:
#     level = 0
#     if level < 1:
#         raise Exception("Invalid level!")           # 触发异常
# except Exception as err:
#     print (1, err)
# else:
#     print( 2)


colum = ["a","b","c"]

x = [i for i in colum]
print(x)

